# udp模块
import socket

from host import host

udp_client1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  # 接收无人机运动的反馈信息
udp_client1.bind((host, 8880))

udp_client2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  # 接收视频流信息
udp_client2.bind((host, 11111))

udp_client3 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  # 接收无人机状态信息
udp_client3.bind((host, 8890))

udp_client4 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  # 接收无人机运动的命令信息，用来绘制路径
udp_client4.bind((host, 20001))

udp_client7 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  # 接收无人机rc运动的stop信息
udp_client7.bind((host, 2001))

udp_client8 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  # 将接收到的视频流转发给识别程序
udp_client8.bind((host, 3001))

udp_client10 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # 接收识别程序发送的circle障碍物的坐标
udp_client10.bind((host, 4001))

command = b'command'
udp_client1.sendto(command, ('192.168.10.1', 8889))
data, addr = udp_client1.recvfrom(4096)
print(data, addr)
command = b'streamon'
udp_client1.sendto(command, ('192.168.10.1', 8889))
data, addr = udp_client1.recvfrom(4096)
print(data, addr)
command = b'setfps high'    # 默认为25帧
udp_client1.sendto(command, ('192.168.10.1', 8889))
data, addr = udp_client1.recvfrom(4096)
print(data, addr)
command = b'setbitrate 1'   # 默认码率不是最高[1,5]
udp_client1.sendto(command, ('192.168.10.1', 8889))
data, addr = udp_client1.recvfrom(4096)
print(data, addr)
command = b'setresolution low'  # (478, 648, 3)和(720, 960, 3)
udp_client1.sendto(command, ('192.168.10.1', 8889))
data, addr = udp_client1.recvfrom(40960)
print(data, addr)
udp_client1.close()



